<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>table</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        ul {
            list-style: none;
            width: 200px;
            margin: 20px auto;
        }
        
        li {
            width: 100px;
            height: 40px;
            float: left;
            line-height: 40px;
            text-align: center;
            font-size: 16px;
            font-weight: 700;
        }
        
        ul li:nth-child(1) {
            background: blue;
        }
        
        ul li:nth-child(2) {
            background: red;
        }
        
        .box div {
            width: 400px;
            height: 200px;
            display: none;
            position: fixed;
            top: 40%;
            left: 50%;
            margin-left: -200px;
            line-height: 200px;
            text-align: center;
            font-size: 18px;
            font-weight: 700;
            transition: all 1s;
        }
        
        .box div:nth-child(1) {
            /* background: blue; */
        }
        
        .box div:nth-child(2) {
            /* background: red; */
        }
        
        .box div.block {
            display: block;
        }
        
        .box div.active {
            opacity: 0.1;
            transform: translateX(100px);
            animation: play 1s linear forwards;
        }
        
        li.name {
            border: 3px solid #ccc;
        }
        
        img {
            width: 100%;
        }
        
        @keyframes play {
            form {
                opacity: 0;
                transform: translateX(0px);
            }
            to {
                opacity: 1;
                transform: translateX(0px);
            }
        }
    </style>
</head>

<body>
    <ul>
        <li class="name">登陆</li>
        <li>注册</li>
    </ul>
    <div class="box">
        <div class="block">登陆</div>
        <div>注册</div>
    </div>

</body>

</html>
<script>
    var uLi = document.querySelectorAll("li");
    var Div = document.querySelectorAll(".box div");
    for (var i = 0; i < uLi.length; i++) {
        uLi[i].index = i;
        uLi[i].onclick = function() {
            for (var j = 0; j < Div.length; j++) {
                Div[j].className = "";
            }
            var i = this.index;
            Div[i].className = "block active";

            for (var k = 0; k < uLi.length; k++) {
                uLi[k].className = "";
            }
            this.className = "name";
        }
    }
</script>